<?php 
$data['page_selected'] = 'management';
$this->load->view('constants/header', $data);?>

<script type="text/javascript">
	$(document).ready(function() {
		$.datepicker.regional['es'] = {
		closeText: 'Cerrar',
		prevText: '&#x3c;Ant',
		nextText: 'Sig&#x3e;',
		currentText: 'Hoy',
		monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
		monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
		'Jul','Ago','Sep','Oct','Nov','Dic'],
		dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
		dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'],
		dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['es']);
		
		$("#birthdate").datepicker({
			dateFormat: 'dd/mm/yy',
			changeMonth: true,
			changeYear: true,
			minDate: "-50Y", 
			maxDate: "+0"
			});
		
	});
</script>

<div id="site_content">
	<?php $this->load->view('constants/sidebar'); ?> 
    <div id="content">
        <!-- insert the page content here -->
        <?php $this->load->view('management/menu'); ?>
        <br /><br /><br /><br />
  		<h3 align="center">Empleados de la Fundaci&oacute;n</h3>
        <a href="<?php echo base_url(); ?>management/new_employee" title="Agregar empleado">
        	<img src="<?php echo base_url().IMG; ?>user_add.png" width="100" height="100"/>
        </a>
        <h1>Editar Empleado</h1>
        <h2 style="font-size:10px"><img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp; Campos Obligatorios</h2>
        <?php echo form_open(base_url().'management/edit_employee/'.$employee['id_empleado']); ?>
        <table width="100%" align="center">
        	<tr>
                <td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Nombre </td>
                <td> <input type="text" name="name" id="name" value="<?php echo $employee['nombre']; ?>"/> </td>
                <td> <?php echo form_error('name'); ?> </td>
            </tr>
            <tr>
                <td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Apellido </td>
                <td> <input type="text" name="lastname" id="lastname" value="<?php echo $employee['apellido']; ?>"/> </td>
                <td> <?php echo form_error('lastname'); ?> </td>
            </tr>
            <tr>
                <td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;C.I. </td>
                <td> <input type="text" name="ci" id="ci" value="<?php echo $employee['ci_empleado']; ?>"/> </td>
                <td> <?php echo form_error('ci'); ?> </td>
            </tr>
            <tr>
                <td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;G&eacute;nero </td>
                <td> 
                    <input type="radio" name="genre" id="genre" value="m" checked="checked" <?php echo set_radio('genre', 'm'); ?>/>M &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                    <input type="radio" name="genre" id="genre" value="f" <?php echo set_radio('genre', 'f'); ?>/>F 
                </td>
                <td></td>
            </tr>
            <tr>
                <td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Fecha de Nacimiento </td>
                <td> <input type="text" name="birthdate" id="birthdate" readonly="readonly" value="<?php echo format_date($employee['fecha_nacimiento']); ?>"/> </td>
                <td> <?php echo form_error('birthdate'); ?> </td>
            </tr>
            <tr>
            	<tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Tel&eacute;fono</td>
                    <td> <input type="text" name="phone" id="phone" value="<?php echo $employee['telefono']; ?>"/> </td>
                    <td> <?php echo form_error('phone'); ?> </td>
                </tr>
            </tr>
            <tr>
            	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Direcci&oacute;n de correo electr&oacute;nico </td>
                <td> <input type="text" name="email" id="email" value="<?php echo $employee['correo_electronico']; ?>"/> </td>
                <td> <?php echo form_error('email'); ?> </td>
            </tr>
            <tr>
                <td> Seud&oacute;nimo de Twitter </td>
                <td> <input type="text" name="twitter" id="twitter" value="<?php echo $employee['twitter']; ?>"/> </td>
                <td> <?php echo form_error('twitter'); ?> </td>
            </tr>
            <tr>
                <td> Facebook </td>
                <td> <input type="text" name="facebook" id="facebook" value="<?php echo $employee['facebook']; ?>"/> </td>
                <td> <?php echo form_error('facebook'); ?> </td>
            </tr>
            <tr>
            	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Cargo</td>
                <td> 
                    <select name="position" id="position"> 
                        <option value="-"  <?php echo set_select('position', '-'); ?>>-----</option>
                        <?php foreach($positions as $p){ 
								if($p['cod_cargo'] == $employee['COD_CARGO']) {?>
                                    <option value="<?php echo $p['cod_cargo'] ?>" selected>
                                        <?php echo $p['descripcion_cargo']; ?>
                                    </option>
                        <?php 	} else { ?>
                        			<option value="<?php echo $p['cod_cargo'] ?>">
                                        <?php echo $p['descripcion_cargo']; ?>
                                    </option>
						<?php 	}
							}?>
                    </select>
                </td>
                <td> <?php echo form_error('position'); ?> </td>
            </tr>
            <tr>
            	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Jefe inmediato</td>
                <td> 
                    <select name="boss" id="boss"> 
                    	<?php if($employee['ID_JEFE_INMEDIATO'] == NULL){ ?>
                        	<option value="-"  selected>-----</option>
                        <?php } else{ ?>
                        	<option value="-">-----</option> 
                        <?php } ?>
                        <?php foreach($employees as $e){ 
								if($e['id_empleado'] == $employee['ID_JEFE_INMEDIATO']) {?>
                                    <option value="<?php echo $e['id_empleado'] ?>" selected>
                                        <?php echo $e['nombre'].' '.$e['nombre']; ?>
                                    </option>
                        <?php 	}else { ?>
                        			<option value="<?php echo $e['id_empleado'] ?>" >
                                        <?php echo $e['nombre'].' '.$e['nombre']; ?>
                                    </option>
                        <?php 	} 
						}?>
                    </select>
                </td>
                <td> <?php echo form_error('boss'); ?> </td>
            </tr>
            <tr>
                <td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Condici&oacute;n </td>
                <td> 
                    <select id="status" name="status">
                        <?php if($employee['condicion'] == 'activo'){ ?>
                            <option value="activo" selected>activo</option>
                            <option value="inactivo">inactivo</option>
                        <?php } 
                        else if($employee['condicion'] == 'inactivo'){ ?>
                            <option value="activo">activo</option>
                            <option value="inactivo" selected>inactivo</option>
                        <?php } ?>
                    </select>
                </td>
                <td></td>
            </tr>
            <tr>
                <td colspan="3" align="right">
                    <input type="submit" name="button" class="submit" value="Procesar" />
                </td>
            </tr>
        </table>
        <h2 style="font-size:10px"><img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp; Campos Obligatorios</h2>
    </div>
</div>
<?php $this->load->view('constants/footer'); ?>